{% extends "personal_center/base.html" %}

{% block page_link %}
    <link rel="stylesheet" href="../../static/public_file/css/PersonnelChooser.css">
{% endblock %}


{% block style %}
    <style>
        .add_class{
            background: #1E90FF;
        }
        .add_background {
            background: #A9A9A9;
        }
        .li-class {
            list-style: none;margin-top: 2%;color: #0b0b0b;cursor: pointer;
        }
        .top_tag {
            border-bottom: #01AAED solid 2px;color: #01AAED;
        }
        .tab_top {
            width: 100px;height: 40px;line-height: 40px;text-align: center;display: inline-block;cursor: pointer;
        }
        .file {
            position: relative;display: inline-block;background: #D0EEFF;border: 1px solid #99D3F5;border-radius: 4px;padding: 4px 12px;overflow: hidden;color: #1E88C7;text-decoration: none;text-indent: 0;line-height: 20px;
        }
        .file input {
            position: absolute;font-size: 100px;right: 0;top: 0;opacity: 0;
        }
        .file:hover {
            background: #AADFFD;border-color: #78C3F3;color: #004974;text-decoration: none;
        }
        .search {
            width: 300px;display: flex;float: right;margin: 10px 0;margin-right: 1%;
        }
        .search input {
            vertical-align: middle;
            float: left;
        / / 左浮动 flex: 4;
            height: 30px;
            width: 230px;
            outline: none;
            border: 1px solid #0070c1;
            box-sizing: border-box;
        / / 盒子模型，怪异IE盒子模型，width = content + border * 2 + padding * 2 padding-left: 10 px;
            border-bottom-left-radius: 3px;border-top-left-radius: 3px;
        }
        .search button {
            float: right;flex: 1;height: 30px;width: 70px;line-height: 30px;background-color: #0070c1;color: white;border-style: none;outline: none;border-bottom-right-radius: 3px;border-top-right-radius: 3px;
        }
        .search button i {
            font-style: normal;
        }
        .search button:hover {
            font-size: 16px;
        }
        #addForm {
            width: 600px;height: 400px;background: #F5F5F5;position: absolute;border: #dfdfdf solid 1px;margin: auto;border-radius: 3px;top: 50%;left: 50%;transform: translate(-50%, -50%);z-index: 10100;font-size: 0;
        }
        #title {
            display: flex;justify-content: space-between;box-sizing: border-box;padding: 0 10px;height: 40px;color: #0b0b0b;cursor: move;width: 100%;background: #f4f7fa;border-top-left-radius: 5px;border-top-right-radius: 5px;
        }
        .div_clase{
            display: inline-block;width: 300px;height: 30px;line-height: 30px;font-size: 14px;color: #0b0b0b;
        }
        .shade1 {
            position: fixed;top: 0;left: 0;right: 0;bottom: 0;background-color: rgba(36, 36, 36, 0.5);display: none;z-index: 10000;
        }
        .search-input {
            width: 95%;height: 30px;border-radius: 3px;border: #cfcfcf solid 1px;background: url(../../static/personal_center/img/input_search.png) no-repeat 4px 5px;background-size: 8%;background-color: white;padding-left: 30px;outline: none;font-size: 14px;
        }
        #processed div {
            padding-left: 2%;
        }
        #processed div:hover {
            background: #cfcfcf;
        }
        #ThreeNavigation div {
            padding-left: 2%;
        }
        .reviewer-confirm {
            width: 100px;height: 30px;margin-top: 10px;border-radius: 3px;letter-spacing: 5px;border: #00a0e9 solid 1px;background: #00a0e9;color: white;
        }
        .reviewer-confirm:hover {
            background: #2db7f5;border: #2db7f5 solid 1px;
        }
        .reviewer-cancel {
            width: 100px;height: 30px;margin-top: 10px;border-radius: 3px;letter-spacing: 5px;border: #cfcfcf solid 1px;background: #cfcfcf;margin-left: 10px;
        }
        .reviewer-cancel:hover {
            background: #F5F5F5;border: #F5F5F5 solid 1px;
        }
    </style>
{% endblock %}


{% block right_content %}
    <div style="width: 100%;height: 40px;background: white;border-bottom: #cfcfcf solid 0.5px;line-height: 40px;padding-left: 1%;color: black;">
        <div id="summit_button" style="float: right;width: 110px;text-align: center;height: 100%;">
            <button id="summ_id" onclick="reviewer_line()" style="width: 100px;height: 30px;margin-top: 5px;border-radius: 3px;border: #1E90FF solid 1px;color: white;background-color: #1E90FF;line-height: 30px;">提&nbsp;&nbsp;交</button>
        </div>
        <div id="save_button" style="float: right;width: 110px;text-align: center;height: 100%;">
            <button id="save_id" onclick="save_fun()" style="width: 100px;height: 30px;margin-top: 5px;border-radius: 3px;border: #1E90FF solid 1px;color: white;background-color: #1E90FF;line-height: 30px;">保&nbsp;&nbsp;存</button>
        </div>
    </div>

    <div id="text_div" style="width: 100%;height: 95%;background: white;">
        <div style="width: 90%;margin-left: 5%;height: 100%;overflow: auto;padding-top: 1%;">
            <div style="width: 100%;">
                <table style="width: 100%;">
                    <tr style="width: 100%;">
                        <td colspan="4" style="width: 100%;height: 40px;line-height: 40px;border: #cccccc solid 1px;padding-left: 1%;text-align: center;"><h3 style="line-height: 50px;">委员会会议纪要</h3></td>
                    </tr>
                    <tr style="width: 100%;">
                        <td colspan="4" style="width: 100%;height: 40px;line-height: 40px;border: #cccccc solid 1px;padding-left: 1%;border-top: none;color: #2db7f5;background: #F5F5F5;">基本信息</td>
                    </tr>
                    <tr style="width: 100%;">
                        <td style="width: 15%;height: 40px;line-height: 40px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;border-top: none;">提&nbsp;交&nbsp;人</td>
                        <td id="ngr" style="width: 35%;height: 40px;line-height: 40px;border: #cccccc solid 1px;border-left: none;padding-left: 1%;border-top: none;">{{ obj.apply_user.real_name }}</td>
                        <td style="width: 15%;height: 40px;line-height: 40px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;border-top: none;">提交科室</td>
                        <td id="ngks" style="width: 35%;height: 40px;line-height: 40px;border: #cccccc solid 1px;border-left: none;padding-left: 1%;border-top: none;">{{ obj.apply_user.company.name }}</td>
                    </tr>
                    <tr style="width: 100%;">
                        <td style="width: 15%;height: 40px;line-height: 40px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;border-top: none;">文&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号</td>
                        <td id="document_number" colspan="3" style="width: 85%;height: 40px;line-height: 40px;border: #cccccc solid 1px;border-left: none;padding-left: 1%;border-top: none;outline: none;">会议纪要〔{{ now_time }}〕{{ a_next_sequence }}号</td>
                    </tr>
                    <tr style="width: 100%;">
                        <td colspan="4" style="width: 100%;height: 40px;line-height: 40px;border: #cccccc solid 1px;padding-left: 1%;border-top: none;color: #2db7f5;background: #F5F5F5;">申请详情</td>
                    </tr>
                    <tr style="width: 100%;">
                        <td style="width: 15%;height: 40px;line-height: 40px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;border-top: none;">拟稿科室</td>
                        <td id="drafting_department" style="width: 35%;height: 40px;line-height: 40px;border: #cccccc solid 1px;border-left: none;padding-left: 1%;border-top: none;" onclick="show_model()">{{ obj.drafter_company }}</td>
                        <td style="width: 15%;height: 40px;line-height: 40px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;border-top: none;">拟&nbsp;稿&nbsp;人</td>
                        <td id="drafted_by" style="width: 35%;height: 40px;line-height: 40px;border: #cccccc solid 1px;border-left: none;padding-left: 1%;border-top: none;" onclick="model_line()">{{ obj.drafter }}</td>
                    </tr>
                    <tr style="width: 100%;">
                        <td style="width: 15%;height: 40px;line-height: 40px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;border-top: none;"><span style="color: red;">* </span>标&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;题</td>
                        <td id="conference_memo_text" colspan="3" style="width: 85%;height: 40px;line-height: 40px;border: #cccccc solid 1px;border-left: none;padding-left: 1%;border-top: none;outline: none;" contenteditable="true">{{ obj.conference_memo_text }}</td>
                    </tr>
                    <tr style="width: 100%;display: none;">
                        <td style="width: 15%;height: 40px;line-height: 40px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;border-top: none;"><span style="color: red;">* </span>印&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;份</td>
                        <td id="servings" colspan="3" style="width: 85%;height: 40px;line-height: 40px;border: #cccccc solid 1px;border-left: none;padding-left: 1%;border-top: none;outline: none;" contenteditable="true">{{ obj.servings }}</td>
                    </tr>
                    <tr style="width: 100%;">
                        <td style="width: 15%;height: 40px;line-height: 40px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;border-top: none;"><span style="color: red;">* </span>主&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;送</td>
                        <td id="main_company" colspan="3" style="width: 85%;height: 40px;line-height: 40px;border: #cccccc solid 1px;border-left: none;padding-left: 1%;border-top: none;outline: none;" contenteditable="true">{{ obj.main_company }}</td>
                    </tr>
                    <tr style="width: 100%;">
                        <td style="width: 15%;height: 40px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;border-top: none;"><span style="color: red;visibility: hidden;">* </span>抄&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;送</td>
                        <td id="vice_company" colspan="3" style="width: 85%;height: 40px;line-height: 40px;border: #cccccc solid 1px;border-left: none;padding-left: 1%;border-top: none;outline: none;" contenteditable="true">{{ obj.vice_company }}</td>
                    </tr>
                </table>
            </div>
            <div style="width: 100%;">
                <table style="width: 100%;">
                    <thead>
                        <tr style="width: 100%;">
                            <td colspan="6" style="width: 100%;height: 40px;line-height: 40px;border: #cccccc solid 1px;padding-left: 1%;border-top: none;color: #2db7f5;background: #F5F5F5;">
                                <span style="color: red;">* </span>上传文件
                                <a href="javascript:;" class="file" style="vertical-align: top;margin-top: 5px;float: right;">
                                    上传文件
                                    <input type="file" name="regular_main_body" id="regular_main_body" onchange="upload_accessory('file1', 'regular_main', 'regular_main_body')">
                                </a>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 5%;height: 35px;border: #cccccc solid 1px;text-align: center;">序号</td>
                            <td style="width: 20%;height: 35px;border: #cccccc solid 1px;border-left: none;text-align: center;">文件名称</td>
                            <td style="width: 20%;height: 35px;border: #cccccc solid 1px;border-left: none;text-align: center;">文件大小</td>
                            <td style="width: 20%;height: 35px;border: #cccccc solid 1px;border-left: none;text-align: center;">上传时间</td>
                            <td style="width: 20%;height: 35px;border: #cccccc solid 1px;border-left: none;text-align: center;">上传人员</td>
                            <td style="width: 15%;height: 35px;border: #cccccc solid 1px;border-left: none;text-align: center;">操作</td>
                        </tr>
                    </thead>
                    <tbody style="overflow: auto;" id="regular_main">
                        {% for record in file_list %}
                            <tr>
                                <td style="width: 5%;border: #cccccc solid 1px;text-align: center;">{{ forloop.counter }}</td>
                                <td style="width: 20%;border: #cccccc solid 1px;border-left: none;text-align: center;">{{ record.file_name }}</td>
                                <td style="width: 20%;border: #cccccc solid 1px;border-left: none;text-align: center;">{{ record.file_size }}</td>
                                <td style="width: 20%;border: #cccccc solid 1px;border-left: none;text-align: center;">{{ record.upload_time }}</td>
                                <td style="width: 20%;border: #cccccc solid 1px;border-left: none;text-align: center;">{{ record.uploader }}</td>
                                <td style="width: 15%;border: #cccccc solid 1px;border-left: none;text-align: center;">
                                    <a target='_blank' href="{{ record.file_path }}">查看</a> | <a style="color: red;" href='#' onclick='RemoveTr(this, "party_main", {{ record.id }})'>删除</a>
                                </td>
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <div id="addForm-fenfa" class="shade1">
        <div id="addForm">
            <!-- 标题 -->
            <div id="title">
                <h5 style="line-height: 40px;width: 15%;margin-left: 1%;display: inline-block;font-size: 14px;">选择科室</h5>
                <span onclick="close_models1()" style="float: right;line-height: 50px;padding-right: 2%;cursor: pointer;"><i class="iconfont icon-quchu"></i></span>
            </div>
            <hr>
            <div style="width: 55%;height: 350px;vertical-align: top;left: 0;display: inline-block;border-right: #cfcfcf solid 1px;">
                <div style="width: 100%;height: 50px;line-height: 50px;padding-left: 2%;">
                    <input id="search_data1" onkeydown="search_dep()" class="search-input" type="text" placeholder="搜索" autocomplete="off">
                </div>
                <div id="processed" style="width: 100%;height: 300px;overflow: auto;">
                    {% for company in company_list %}
                        <div style="width: 100%;height: 30px;line-height: 30px;font-size: 14px;color: #0b0b0b;">
                            <input class="check_box1" id="{{ company.id }}" type="checkbox" onclick="check_dep_ff('{{ company.name }}', '{{ company.id }}')"> {{ company.name }}
                        </div>
                    {% endfor %}
                </div>
            </div>

            <div style="width: 43%;height: 360px;vertical-align: top;left: 0;display: inline-block;">
                <div style="width: 100%;height: 50px;line-height: 50px;padding-left: 2%;font-size: 14px;">
                    已选择科室
                </div>
                <div id="processed_prople" style="width: 100%;height: 265px;overflow: auto;padding-left: 2%;">

                </div>
                <div style="width: 100%;height: 40px;text-align: center;">
                    <button onclick="Distribution_department()" style="border-radius: 2px;height: 30px;margin-top: 5px;border: #1E90FF solid 1px;background: #1E90FF;color: white;width: 80px;letter-spacing: 4px;font-size: 14px;">
                        提交
                    </button>
                    <button onclick="close_models1()" style="border-radius: 2px;height: 30px;margin-top: 5px;border: #cfcfcf solid 1px;width: 80px;letter-spacing: 4px;margin-left: 15px;font-size: 14px;">
                        取消
                    </button>
                </div>
            </div>
        </div>
    </div>

    <div id="staff-select" class="shade">
        <div id="staff-model" style="width: 100%;height: 100%;position: absolute;">
            <div style="width: 900px;height: 500px;background: #F5F5F5;z-index: 10000;position: absolute;top: 50%;left: 50%;transform:translate(-50%,-50%);border-radius: 3px;border: #dfdfdf solid 1px;">
                <div id="staff-box" style="width: 100%;height: 40px;background: #f4f7fa;cursor: move;border-top-left-radius: 5px;border-top-right-radius: 5px;border-bottom: #dfdfdf solid 1px;">
                    <div style="width: 20%;margin-left: 1%;display: inline-block;line-height: 40px;font-size: 14px;">
                        选择人员
                    </div>
                    <span onclick="close_model()" style="float: right;padding-right: 2%;cursor: pointer;line-height: 40px;">
                        <i class="iconfont icon-quchu"></i>
                    </span>
                </div>
                <div style="height: 460px;width: 100%;border-bottom: #dfdfdf solid 1px;">
                    <div style="width: 70px;height: 100%;border-right: #cfcfcf solid 1px;display: inline-block;vertical-align: top;">
                        <div id="dep" class="navigation navigation_color" onclick="change_navigation(this)">部门</div>
                        <div id="limits" class="navigation" onclick="change_navigation(this)">权限</div>
                        <div id="fun" class="navigation" onclick="change_navigation(this)">职能</div>
                    </div>
                    <div style="width: 200px;height: 100%;border-right: #cfcfcf solid 1px;display: inline-block;vertical-align: top;">
                        <div style="width: 100%;height: 50px;line-height: 50px;">
                            <input id="SearchDep" onkeydown="SearchDepartment()" class="search_input" type="text" placeholder="搜索" autocomplete="off" style="width: 95%;">
                        </div>
                        <div id="SecondaryNavigation" style="width: 100%;height: 403px;line-height: 50px;overflow: auto;"></div>
                    </div>
                    <div style="width: 200px;height: 100%;border-right: #cfcfcf solid 1px;display: inline-block;vertical-align: top;">
                        <div style="width: 100%;height: 50px;line-height: 50px;padding-left: 2%;">
                            <input type="checkbox" id="select-all" onclick="SelectAll(this)">
                            <input id="SearchPeo" onkeydown="SearchProple()" class="search_input" type="text" placeholder="搜索" autocomplete="off" style="width: 87%;">
                        </div>
                        <div id="ThreeNavigation" style="width: 100%;height: 403px;line-height: 50px;overflow: auto;"></div>
                    </div>
                    <div style="width: 370px;height: 100%;display: inline-block;vertical-align: top;overflow: auto">
                        <div style="width: 100%;height: 40px;text-align: left;font-size: 14px;line-height: 40px;">
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;已选 <span id="selected-number">0</span> 人
                        </div>
                        <div id="selected-div" style="width: 100%;font-size: 14px;height: 370px;overflow: auto;line-height: 20px;">

                        </div>
                        <div style="width: 100%;font-size: 14px;height: 40px;text-align: center;">
                            <button id="finish_with" onclick="IdentifyPersonnel()" style="width: 100px;height: 30px;line-height: 25px;text-align: center;letter-spacing: 5px;border-radius: 3px;border: #cfcfcf solid 1px;font-size: 14px;cursor: pointer;margin-top: 10px;">完成</button>
                            <button onclick="close_model()" style="margin-left: 15px;width: 100px;height: 30px;line-height: 25px;text-align: center;color: #0abb78;letter-spacing: 5px;border-radius: 3px;font-size: 14px;border: #cfcfcf solid 1px;cursor: pointer;margin-top: 10px;">取消</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div id="Reviewer" class="shade" style="z-index: 9000;">
        <div id="reviewer-model" style="width: 100%;height: 100%;position: absolute;">
            <div style="width: 500px;height: 250px;background: white;z-index: 10000;position: absolute;top: 50%;left: 50%;transform:translate(-50%,-50%);border-radius: 3px;border: #dfdfdf solid 1px;">
                <div id="reviewer-box" style="width: 100%;height: 40px;cursor: move;border-top-left-radius: 5px;border-top-right-radius: 5px;border-bottom: #cfcfcf solid 1px;">
                    <div style="width: 20%;margin-left: 1%;display: inline-block;line-height: 40px;font-size: 14px;">
                        审批人员
                    </div>
                    <span onclick="close_model1()" style="float: right;padding-right: 2%;cursor: pointer;line-height: 40px;">
                        <i class="iconfont icon-quchu"></i>
                    </span>
                </div>
                <div style="height: 165px;width: 100%;padding-top: 20px;text-align: center;">
                    <div style="width: 100%;height: 40px;line-height: 40px;">
                        <label for="" style="font-size: 12px;">委员会办公室审核人：</label>
                        <input type="text" id="OfficeReviewer" style="width: 280px;border: #cfcfcf solid 1px;border-radius: 3px;height: 30px;" onclick="model_line_with_parameters(this.id)">
                    </div>
                    <div style="width: 100%;height: 40px;line-height: 40px;">
                        <label for="" style="font-size: 12px;letter-spacing: 1.1px;">会&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;签&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;人&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;员：</label>
                        <input type="text" id="CountersignReviewer" onclick="model_line_with_parameters(this.id)" style="width: 280px;border: #cfcfcf solid 1px;border-radius: 3px;height: 30px;">
                    </div>
                    <div style="width: 100%;height: 40px;line-height: 40px;">
                        <label for="" style="font-size: 12px;letter-spacing: 1.1px;">签&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;发&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;人&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;员：</label>
                        <input type="text" id="IssuanceReviewer" onclick="model_line_with_parameters(this.id)" style="width: 280px;border: #cfcfcf solid 1px;border-radius: 3px;height: 30px;">
                    </div>
                </div>
                <div style="width: 100%;height: 40px;text-align: center;">
                    <button class="reviewer-confirm" onclick="summit_fun()">确认</button>
                    <button class="reviewer-cancel" onclick="close_model1()">取消</button>
                </div>
            </div>
        </div>
    </div>
{% endblock %}


{% block script %}
    <script src="../../static/public_file/js/PersonnelChoosersNew.js" type="text/javascript" charset="gb2312"></script>
    <script>
        window.onload = function () {
            document.getElementById("supervision_inspection_management").className = "add_class";
            document.getElementById("personage").className = "add-nav-active";
        };

        let title = document.querySelector("#title");
        let addForm = document.querySelector("#addForm");

        title.addEventListener("mousedown", function (e) {
            let x = e.pageX - addForm.offsetLeft;
            let y = e.pageY - addForm.offsetTop;

            document.addEventListener("mousemove", move);
            function move(e) {
                addForm.style.left = e.pageX - x + 'px';
                addForm.style.top = e.pageY - y + 'px';
            }

            document.addEventListener("mouseup", function (e) {
                document.removeEventListener("mousemove", move);
            })
        });

        let reviewer_box = document.querySelector("#reviewer-box");
        let reviewer_model = document.querySelector("#reviewer-model");

        reviewer_box.addEventListener("mousedown", function (e) {
            let x = e.pageX - reviewer_model.offsetLeft;
            let y = e.pageY - reviewer_model.offsetTop;

            document.addEventListener("mousemove", move);
            function move(e) {
                reviewer_model.style.left = e.pageX - x + 'px';
                reviewer_model.style.top = e.pageY - y + 'px';
            }

            document.addEventListener("mouseup", function (e) {
                document.removeEventListener("mousemove", move);
            })
        });

        var department = "{{ department | safe }}";
        var realname = "{{ realname | safe }}";

        function show_model() {
            document.getElementById("addForm-fenfa").style.display="table-row";
        }

        function close_models1() {
            document.getElementById("addForm-fenfa").style.display = "none";
        }

        // 删除列表
        function deltr1() {
            var tb = document.getElementById('t_table2');
            var rowNum = tb.rows.length;
            for (i = 0; i < rowNum; i++) {
                tb.deleteRow(i);
                rowNum = rowNum - 1;
                i = i - 1;
            }
        }



        var company_list = {{ company_list | safe }};

        function search_dep(){
            var search_keyword = document.getElementById("search_data1").value;
            var processed = document.getElementById("processed");
            processed.innerHTML = "";
            console.log(company_list.length)
            for (var h=0; h<company_list.length; h++){
                if (company_list[h]["name"].indexOf(search_keyword) !== -1){
                    console.log(company_list[h]["name"])
                    var div_tag = document.createElement("div");div_tag.className="div_clase";
                    div_tag.innerHTML = '<input class="check_box1" id="'+company_list[h]["id"]+'" type="checkbox" onclick="check_dep_ff(\''+company_list[h]["name"]+'\', \''+company_list[h]["id"]+'\')"> '+ company_list[h]["name"];
                    processed.appendChild(div_tag)
                }
            }
        }

        function check_dep_ff(ele_name, ele_id) {
            var processed_prople = document.getElementById("processed_prople");
            {#var span = document.createElement("span");#}
            console.log(document.getElementById(ele_id).checked)
            if (!document.getElementById(ele_id).checked){
                document.getElementById(ele_id).checked = false;
                processed_prople.innerText = "";
            }
            if (document.getElementById(ele_id).checked){
                {#span.innerText=ele_name;span.setAttribute("id", 'cc-'+ele_id);span.style.fontSize='14px';span.style.marginLeft="10px";#}
                processed_prople.innerText = ele_name;processed_prople.style.color='#4169E1';processed_prople.style.fontSize='14px';
                check_more_one_not1(ele_id);
            }
        }

        function Distribution_department() {
            var processed_prople = document.getElementById("processed_prople").innerText;

            if (!processed_prople){
                alert("请选择拟稿科室！");
                return false
             }
            close_models1()
            document.getElementById("drafting_department").innerText=processed_prople;
         }

        function summit_fun() {
            var form = new FormData();
            var OfficeReviewer = document.getElementById("OfficeReviewer").value;           // 委员会办公室审核人
            var CountersignReviewer = document.getElementById("CountersignReviewer").value;           // 会签人员
            var IssuanceReviewer = document.getElementById("IssuanceReviewer").value;           // 签发人员
            var document_number = document.getElementById("document_number").innerText;                                // 纪要编号
            var drafting_department = document.getElementById("drafting_department").innerText;
            var drafted_by = document.getElementById("drafted_by").innerText;
            var conference_memo_text = document.getElementById("conference_memo_text").innerText;
            var main_company = document.getElementById("main_company").innerText;
            var vice_company = document.getElementById("vice_company").innerText;
            var servings = document.getElementById("servings").innerText;

            if (!OfficeReviewer) {
                alert("请选择委员会办公室审核人！")
                return false
            }
            if (!CountersignReviewer) {
                alert("请选择会签人员！")
                return false
            }
            if (!IssuanceReviewer) {
                alert("请选择签发人员！")
                return false
            }
            if (!drafting_department){
                alert("请选择拟稿科室！")
                return false
            }
            if (!drafted_by){
                alert("请选择拟稿人！")
                return false
            }
            if (!main_company){
                alert("主送不能为空！")
                return false
            }
            if (!conference_memo_text){
                alert("标题不能为空！")
                return false
            }
            var t_table = document.getElementById('regular_main').childNodes.length;
            if (t_table === 0){
                alert("请上传附件！")
                return false
            }
            form.append("OfficeReviewer", OfficeReviewer)
            form.append("CountersignReviewer", CountersignReviewer)
            form.append("IssuanceReviewer", IssuanceReviewer)
            form.append("document_number", document_number)
            form.append("drafting_department", drafting_department)
            form.append("drafted_by", drafted_by)
            form.append("conference_memo_text", conference_memo_text)
            form.append("main_company", main_company)
            form.append("vice_company", vice_company)
            form.append("servings", servings)
            form.append("uuid", '{{ obj.fj_number }}')
            form.append("id", '{{ obj.id }}')
            document.getElementById("loading").style.display = "inline-block";
            var xhr = new XMLHttpRequest();
            xhr.open('post', "/supervision-inspection/summary_application_index.html", true);
            xhr.send(form);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        console.log(JsonDate);
                        if (JsonDate['code']===200) {
                            alert("提交成功！")
                            window.location.href = "my_draft.html";
                        }else {
                            alert(JsonDate['message'])
                        }
                    }
                }
             };
        }

        function save_fun() {
            var form = new FormData();
            var document_number = document.getElementById("document_number").innerText;                                // 纪要编号
            var drafting_department = document.getElementById("drafting_department").innerText;
            var drafted_by = document.getElementById("drafted_by").innerText;
            var conference_memo_text = document.getElementById("conference_memo_text").innerText;
            var main_company = document.getElementById("main_company").innerText;
            var vice_company = document.getElementById("vice_company").innerText;
            var servings = document.getElementById("servings").innerText;

            form.append("document_number", document_number)
            form.append("drafting_department", drafting_department)
            form.append("drafted_by", drafted_by)
            form.append("conference_memo_text", conference_memo_text)
            form.append("main_company", main_company)
            form.append("vice_company", vice_company)
            form.append("servings", servings)
            form.append("uuid", '{{ obj.fj_number }}')
            form.append("id", '{{ obj.id }}')
            document.getElementById("loading").style.display = "inline-block";
            var xhr = new XMLHttpRequest();
            xhr.open('post', "/supervision-inspection/summary_application_draft.html", true);
            xhr.send(form);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        console.log(JsonDate);
                        if (JsonDate['code']===200) {
                            alert("保存成功！")
                            window.location.href = "my_draft.html";
                        }else {
                            alert(JsonDate['message'])
                        }
                    }
                }
             };
        }

        function upload_accessory(file_type, tbody_id, accessory_type) {
            document.getElementById("loading").style.display = "inline-block";
            var form = new FormData();
            var files = document.getElementById(accessory_type).files[0];
            form.append(file_type, files);
            form.append('number', '{{ obj.fj_number }}')
            form.append("source", "wyhjy")
            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/administrative/topics_attachments_upload", true);
            xhr.send(form);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        console.log(JsonDate);
                        creat_table(JsonDate, tbody_id);
                        document.getElementById("regular_main_body").value="";
                    }
                }
            };
        }

        // 创建附件列表
        function creat_table(JsonData, tbody_id) {
            var t_table = document.getElementById(tbody_id);
            var local_host = window.location.host;
            if (Array.isArray(JsonData["pdf_path"])){
                for (var i=0; i<JsonData["pdf_path"].length; i++){
                    var tr = document.createElement("tr");
                    var td1 = document.createElement("td");var td2 = document.createElement("td");var td3 = document.createElement("td");var td4 = document.createElement("td");var td5 = document.createElement("td");var td6 = document.createElement("td");
                    td1.innerHTML = t_table.children.length+1;td1.style.textAlign = "center";td1.style.border="#cccccc solid 1px";td1.style.borderTop="none";
                    td2.innerHTML = JsonData["file_name"];td2.style.paddingLeft = "1%";td2.style.border="#cccccc solid 1px";td2.style.borderLeft="none";td2.style.borderTop="none";
                    td3.innerHTML = JsonData["file_size"];td3.style.textAlign = "center";td3.style.border="#cccccc solid 1px";td3.style.borderLeft="none";td3.style.borderTop="none";
                    td4.innerHTML = JsonData["upload_time"];td4.style.textAlign = "center";td4.style.border="#cccccc solid 1px";td4.style.borderLeft="none";td4.style.borderTop="none";
                    td5.innerHTML = JsonData["uploader"];td5.style.textAlign = "center";td5.style.border="#cccccc solid 1px";td5.style.borderLeft="none";td5.style.borderTop="none";
                    td6.innerHTML = "<a target='_blank' href='"+JsonData["pdf_path"][i]["pdf_path"] + "'>查看</a> | <a style='color: red;' href='#' onclick='RemoveTr(this, \""+tbody_id+"\", \""+JsonData["pdf_path"][i]["id"]+"\")'>删除</a>";td6.style.textAlign = "center";td6.style.border="#cccccc solid 1px";td6.style.borderLeft="none";td6.style.borderTop="none";
                    tr.appendChild(td1);tr.appendChild(td2);tr.appendChild(td3);tr.appendChild(td4);tr.appendChild(td5);tr.appendChild(td6);
                    t_table.appendChild(tr);
                }
                if (JsonData["pdf_path"].length > 1){
                    document.getElementById("del_adjunct").style.display='block';
                }
            }else {
                var tr = document.createElement("tr");
                var td1 = document.createElement("td");var td2 = document.createElement("td");var td3 = document.createElement("td");var td4 = document.createElement("td");var td5 = document.createElement("td");var td6 = document.createElement("td");
                td1.innerHTML = t_table.children.length+1;td1.style.textAlign = "center";td1.style.border="#cccccc solid 1px";td1.style.borderTop="none";
                td2.innerHTML = JsonData["file_name"];td2.style.paddingLeft = "1%";td2.style.border="#cccccc solid 1px";td2.style.borderLeft="none";td2.style.borderTop="none";
                td3.innerHTML = JsonData["file_size"];td3.style.textAlign = "center";td3.style.border="#cccccc solid 1px";td3.style.borderLeft="none";td3.style.borderTop="none";
                td4.innerHTML = JsonData["upload_time"];td4.style.textAlign = "center";td4.style.border="#cccccc solid 1px";td4.style.borderLeft="none";td4.style.borderTop="none";
                td5.innerHTML = JsonData["uploader"];td5.style.textAlign = "center";td5.style.border="#cccccc solid 1px";td5.style.borderLeft="none";td5.style.borderTop="none";
                td6.innerHTML = "<a target='_blank' href='"+JsonData["pdf_path"] + "'>查看</a> | <a style='color: red;' href='#' onclick='RemoveTr(this, \""+tbody_id+"\", \""+JsonData["id"]+"\")'>删除</a>";td6.style.textAlign = "center";td6.style.border="#cccccc solid 1px";td6.style.borderLeft="none";td6.style.borderTop="none";
                tr.appendChild(td1);tr.appendChild(td2);tr.appendChild(td3);tr.appendChild(td4);tr.appendChild(td5);tr.appendChild(td6);
                t_table.appendChild(tr);
            }
        }

        function RemoveTr(_this, tbody_id, wj_id) {
            var table = document.getElementById(tbody_id);
            var trNode = $(_this).parent().parent();
            trNode.remove();

            for (var i=0; i<table.children.length; i++){
                table.children[i].children[0].innerHTML=i+1;
            }

            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/administrative/delete_attachments_view", true);
            xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
            xhr.send("id="+String(wj_id));
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        console.log(JsonDate);
                        alert("删除成功！")
                    }
                }
            };
        }

        // checkBox不允许多选
        function check_more_one_not1(ele_id) {
            var check_box_list = document.getElementsByClassName("check_box1");
            for (var i = 0; i < check_box_list.length; i++) {
                if (String(check_box_list[i].id) !== String(ele_id)) {
                    document.getElementById(check_box_list[i].id).checked = false;
                } else {
                    document.getElementById(check_box_list[i].id).checked = true;
                }
            }
        }

        function IdentifyPersonnel(ele_id='drafted_by') {
            var prople_list = [];
            var selected_personnel_list = document.getElementsByClassName('selected-personnel');
            for (var i=0; i<selected_personnel_list.length; i++) {
                prople_list.push(selected_personnel_list[i].innerText)
            }
            if (ele_id === 'drafted_by') {
                document.getElementById(ele_id).innerText = prople_list[0].split("(")[0];
            }else {
                document.getElementById(ele_id).value = prople_list;
            }

            close_model()
        }

        function scrollConversationScreen() {
            $('#selected-div').scrollTop($('#selected-div')[0].scrollHeight);
        }

        function reviewer_line() {
            document.getElementById("Reviewer").style.display = "table-row";
        }

        function close_model1() {
            document.getElementById("Reviewer").style.display = "none";
        }
    </script>
{% endblock %}
